package com.database.service;

import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

public interface IBasicService<Model, PK extends Serializable> extends IService<Model> {

    int insert(Model record);

    int deleteByPrimaryKey(PK id);

    /**
     * 根据id条件更新实体`record`包含的全部属性，null值会被更新
     * 条件中必须包含主键
     */
    int updateByPrimaryKey(Model record);

    int updateByPrimaryKeySelective(Model record);

    Model selectByPrimaryKey(PK id);

    // 查询
    List<Model> selectListBySearch(Model record);

    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    int deleteByKeys(List<PK> keys);

}
